﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.UserModel;
using System.Reflection;
using System.Text.Json.Nodes;
using WcMatch.Consts;
using WcMatch.Models;

namespace WcMatch.Controllers
{
    [Route("[controller]/[action]")]
    [ApiController]
    public class CollegeController : ControllerBase
    {
        CollegeContext _cCxt;
        UniversityContext _uniCxt;
        RecruitmentApplicationCxt _raCxt;
        CompanyContext _comCxt;
        JobContext _jobCxt;
        StuResumeContext _stuResumeContext;
        StudentContext _studentCxt;
        EthnicKindContext _ekCxt;
        UniversityDivisionContext _udCxt;
        DistrictContext _cityCxt;
        IWebHostEnvironment _webHostEnvironment;



        public CollegeController(UniversityContext uniCxt,
                                    RecruitmentApplicationCxt raCxt,
                                    CompanyContext comCxt,
                                    JobContext jobContext,
                                    StudentContext studentContext,
                                    StuResumeContext stuResumeContext,
                                    EthnicKindContext ekCxt,
                                    UniversityDivisionContext udCxt,
                                    DistrictContext cityCxt,
                                    CollegeContext cCxt,
                                    IWebHostEnvironment webHost)
        {
            _uniCxt = uniCxt;
            _raCxt = raCxt;
            _comCxt = comCxt;
            _jobCxt = jobContext;
            _studentCxt = studentContext;
            _stuResumeContext = stuResumeContext;
            _ekCxt = ekCxt;
            _udCxt = udCxt;
            _cityCxt = cityCxt;
            _cCxt = cCxt;
            _webHostEnvironment = webHost;
        }

        [HttpPost]
        public async Task<IActionResult> Login(string uname, string pwd)
        {
            if (string.IsNullOrEmpty(uname) || string.IsNullOrEmpty(pwd))
                return BadRequest(new ActionStatus(-1, "参数异常"));

            var user = _cCxt.Colleges.Where(s => s.UName == uname && s.Pwd == pwd).FirstOrDefault();
            if (user == null)
                return NotFound(new ActionStatus(-1, "账号或密码错误"));
            if(user.Uid == null)
            {
                user.Uid = Guid.NewGuid().ToString();
                await _cCxt.SaveChangesAsync();
            }
            return Ok(new ActionStatus(200, "登录成功", user.Uid));
        }

        [HttpGet]
        public async Task<IActionResult> Get(string uid)
        {
            if (string.IsNullOrEmpty(uid))
                return BadRequest(new ActionStatus(-1,"参数异常"));
            var user = _cCxt.Colleges.Where(s => s.Uid == uid).FirstOrDefault();
            if (user == null) 
                return NotFound(new ActionStatus(-1, "用户不存在"));
            return Ok(new ActionStatus(200, "获取成功", user));
        }

        [HttpPost]
        public async Task<IActionResult> AddRole(string uid, [FromForm]IFormCollection dict)
        {
            if (string.IsNullOrEmpty(uid))
                return BadRequest(new ActionStatus(-1, "参数异常"));
            
            College u = _cCxt.Colleges.Where(s=>s.Uid == uid).FirstOrDefault();   
            if (u == null)
                return BadRequest(new ActionStatus(-1, "操作员账号不存在"));
            if (u.Role != 1)
                return Unauthorized(new ActionStatus(-1, "操作员权限不足"));

            College c = new College();   
            if(!ParseUserForm(ref c, dict))
                return BadRequest(new ActionStatus(-1, "参数异常"));
            if (c.CollegeId != u.CollegeId)
                return Unauthorized(new ActionStatus(-1, "操作员仅可管理本院系账号"));

            u = _cCxt.Colleges.Where(s=>s.UName == c.UName).FirstOrDefault();
            if (u != null)
                return BadRequest(new ActionStatus(-1, "账号不可用，请更换后重试"));


            _cCxt.Add(c);
            int line = await _cCxt.SaveChangesAsync();
            if(line > 0)
                return Ok(new ActionStatus(200, "新增成功", c));
            else
                return BadRequest(new ActionStatus(-1, "内部错误，新增失败"));

        }

        private bool ParseUserForm(ref College uni, IFormCollection dict)
        {
            if(dict.Keys.Count == 0)
                return false;
            PropertyInfo[] pis = uni.GetType().GetProperties();
            foreach (var pi in pis)
            {
                string name = pi.Name.ToLower();
                if (dict.ContainsKey(name) && dict[name].Count() != 0)
                {
                    var value = dict[name][0];
                    if (pi.PropertyType.FullName.Contains("DateTime"))
                    {
                        DateTime dt;
                        if (!DateTime.TryParse(value, out dt))
                            return false;
                        pi.SetValue(uni, dt);
                    }
                    else if (pi.PropertyType.FullName.Contains("Int32"))
                    {
                        int v;
                        if(!int.TryParse(value, out v))
                            return false;
                        pi.SetValue(uni, v);
                    }
                    else if (pi.PropertyType.FullName.Contains("String"))
                    {
                        pi.SetValue(uni, value);
                    }
                }
            }
            return true;
        }

        //-------------------------------------------------------------------------------
        #region 获取企业、企业的招聘信息
        [HttpGet]
        public IActionResult AllJobs(string college)
        {
            var lst = _jobCxt.Jobs.Where(s => s.ExpiryDate >= DateTime.Today  && s.CollegeRequirement == college);
            return Ok(new ActionStatus(200, "查找成功", lst));
        }

        [HttpPost]
        public IActionResult GetJobsBy(string college, [FromForm] IFormCollection dict)//string name, string major, string degree, string comName, int mins
        {
            var lst = _jobCxt.Jobs.Where(s => s.ExpiryDate >= DateTime.Today && s.CollegeRequirement == college).ToList();
            if (lst.Count() == 0)
                return Ok(new ActionStatus(200, "暂无有效岗位"));
            string name = string.Empty,  major = string.Empty, degree = string.Empty, comName = string.Empty;
            int mins = -1;

            if (dict.ContainsKey("mins"))
                if (!int.TryParse(dict["mins"][0], out mins))
                    return BadRequest(new ActionStatus(-1, "参数异常"));

            if (dict.ContainsKey("name")) name = dict["name"][0];
            if (dict.ContainsKey("major")) major = dict["major"][0];
            if (dict.ContainsKey("degree")) degree = dict["degree"][0];
            if (dict.ContainsKey("comName")) comName = dict["comName"][0];
            lst = FindJobBy(lst, name, major, degree, comName, mins);
            return Ok(new ActionStatus(200, "查找成功", lst));
        }

        private List<Job> FindJobBy(IEnumerable<Job> lst, string name, string major, string degree, string comName, int mins)
        {
            lst = lst.Where(s => s.MaxWage >= mins);
            if (!string.IsNullOrEmpty(name)) lst = lst.Where(s => s.Name == name);
            if (!string.IsNullOrEmpty(major)) lst = lst.Where(s => s.MajorRequirement == major);
            if (!string.IsNullOrEmpty(degree)) lst = lst.Where(s => s.DegreeRequirement == degree);
            if (!string.IsNullOrEmpty(comName)) lst = lst.Where(s => s.CompanyName == comName);
            return lst.ToList();
        }


        [HttpGet]
        public IActionResult GetJobsLike(string college, string con)
        {
            if (string.IsNullOrEmpty(con))
                return BadRequest(new ActionStatus(-1, "参数异常"));
            var lst = _jobCxt.Jobs.Where(s => s.ExpiryDate >= DateTime.Today && s.CollegeRequirement == college);
            lst = lst.Where(s=>s.MajorRequirement.Contains(con) ||
                            s.DegreeRequirement.Contains(con) ||
                            s.CompanyName.Contains(con) ||
                            s.Name.Contains(con));

            return Ok(new ActionStatus(200, "查找成功", lst));

        }
        #endregion

        #region 就业与职业发展
        [HttpGet]
        public IActionResult CareerDefault(string college)
        {
            var year = DateTime.Now.AddYears(-1);
            var resumeGroups = _stuResumeContext.Resumes.Where(s => s.UpdateTime > year).GroupBy(s => s.CitizenId);

            List<StudentWithResume> srs = new List<StudentWithResume>();

            foreach (var item in resumeGroups)
            {
                string cid = item.Key;
                var student = _studentCxt.Students.Where(s => s.CitizenId == cid && s.College == college).FirstOrDefault();
                if (student == null) continue;
                StudentWithResume sr = new StudentWithResume();
                sr.Brief = student;
                foreach (var resume in item)
                {
                    sr.Resumes.Add(resume);
                }
                srs.Add(sr);
            }
            return Ok(new ActionStatus(200, "查找成功", srs));
        }

        [HttpPost]
        public IActionResult SearchBy(string college, [FromForm] IFormCollection dict)
        {
            string name = null, major = null, cType = null, cName = null, startDt = null, endDt = null;
            DateTime dtStart, dtEnd;
            if (dict.Keys.Count == 0)
                return BadRequest(new ActionStatus(-1, "检索参数不可为空"));
            if (dict.ContainsKey("name")) name = dict["name"];
            if (dict.ContainsKey("major")) major = dict["major"];
            if (dict.ContainsKey("cType")) cType = dict["cType"];
            if (dict.ContainsKey("cName")) cName = dict["cName"];
            if (dict.ContainsKey("startDt")) startDt = dict["startDt"];
            if (dict.ContainsKey("endDt")) endDt = dict["endDt"];

            //List<StuResume> lst = null;
            List<Student> lstStu = null;
            List<Company> lstCs = null;

            var stuss = _studentCxt.Students.Where(s => s.College == college);
            IQueryable<StuResume> stuRe = null;

            if (!string.IsNullOrEmpty(name))
            {
                stuRe = _stuResumeContext.Resumes.Where(s => s.Name == name);
                stuss = stuss.Where(s => s.Name == name);
                if (stuRe.Count() == 0 || stuss.Count() == 0)
                    return Ok(new ActionStatus(-1, "未检索到"));
            }
            if (!string.IsNullOrEmpty(major))
            {
                stuss = stuss.Where(s => s.Major == major);
                var cids = stuss.Select(s => s.CitizenId).ToList();
                if (stuRe == null)
                    stuRe = _stuResumeContext.Resumes.Where(s => cids.Contains(s.CitizenId));
                else
                    stuRe = stuRe.Where(s => cids.Contains(s.CitizenId));
                if (stuRe.Count() == 0 || stuss.Count() == 0)
                    return Ok(new ActionStatus(-1, "未检索到"));
            }
            if (!string.IsNullOrEmpty(cType))
            {
                lstCs = _comCxt.Companies.Where(s => s.CompanyType == cType).ToList();
                var comIds = lstCs.Select(s => s.CompanyId).ToList();

                if (stuRe == null)
                    stuRe = _stuResumeContext.Resumes.Where(s => comIds.Contains(s.CompanyId));
                else
                    stuRe = stuRe.Where(s => comIds.Contains(s.CompanyId));
                if (stuRe.Count() == 0 || stuss.Count() == 0)
                    return Ok(new ActionStatus(-1, "未检索到"));
            }
            if (!string.IsNullOrEmpty(cName))
            {
                lstCs = _comCxt.Companies.Where(s => s.Name == cName).ToList();
                var comIds = lstCs.Select(s => s.CompanyId).ToList();

                if (stuRe == null)
                    stuRe = _stuResumeContext.Resumes.Where(s => comIds.Contains(s.CompanyId));
                else
                    stuRe = stuRe.Where(s => comIds.Contains(s.CompanyId));
                if (stuRe.Count() == 0 || stuss.Count() == 0)
                    return Ok(new ActionStatus(-1, "未检索到"));
            }
            if (!string.IsNullOrEmpty(startDt))
            {
                if (!DateTime.TryParse(startDt, out dtStart))
                    return BadRequest(new ActionStatus(-1, "参数异常"));
                if (lstStu == null)
                    lstStu = _studentCxt.Students.Where(s => s.GraduationYear >= dtStart).ToList();
                else
                    lstStu = lstStu.Where(s => s.GraduationYear >= dtStart).ToList();
                var cids = lstStu.Select(s => s.CitizenId).ToList();
                if (stuRe == null)
                    stuRe = _stuResumeContext.Resumes.Where(s => cids.Contains(s.CitizenId));
                else
                    stuRe = stuRe.Where(s => cids.Contains(s.CitizenId));
                if (stuRe.Count() == 0 || stuss.Count() == 0)
                    return Ok(new ActionStatus(-1, "未检索到"));
            }
            if (!string.IsNullOrEmpty(endDt))
            {
                if (!DateTime.TryParse(endDt, out dtEnd))
                    return BadRequest(new ActionStatus(-1, "参数异常"));
                if (lstStu == null)
                    lstStu = _studentCxt.Students.Where(s => s.GraduationYear >= dtEnd).ToList();
                else
                    lstStu = lstStu.Where(s => s.GraduationYear >= dtEnd).ToList();
                var cids = lstStu.Select(s => s.CitizenId).ToList();
                if (stuRe == null)
                    stuRe = _stuResumeContext.Resumes.Where(s => cids.Contains(s.CitizenId));
                else
                    stuRe = stuRe.Where(s => cids.Contains(s.CitizenId));
                if (stuRe.Count() == 0 || stuss.Count() == 0)
                    return Ok(new ActionStatus(-1, "未检索到"));
            }
            if (stuRe == null)
                return BadRequest(new ActionStatus(-1, "检索参数不可为空"));
            var resumeGroups = stuRe.GroupBy(s => s.CitizenId);
            List<StudentWithResume> srs = new List<StudentWithResume>();
            foreach (var item in resumeGroups)
            {
                string cid = item.Key;
                var student = _studentCxt.Students.Where(s => s.CitizenId == cid).FirstOrDefault();
                if (student == null)
                    continue;
                StudentWithResume sr = new StudentWithResume();
                sr.Brief = student;
                foreach (var resume in item)
                {
                    sr.Resumes.Add(resume);
                }
                srs.Add(sr);
            }
            return Ok(new ActionStatus(200, "查找成功", srs));
        }
        #endregion

        //[HttpPost]
        //public async Task<IActionResult> ImportStudents([FromForm] IFormCollection dict)
        //{
        //    //application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
        //    //application/vnd.ms-excel
        //    //text / csv
        //    //ContentType 
        //    IFormFile file = dict.Files["file"];
        //    if (file == null)
        //        return BadRequest(new ActionStatus(-1, "参数异常"));
        //    string fileExten = Path.GetExtension(file.FileName).ToLower();
        //    if (!GlobalDefines.ExcelTypeDict.Keys.Contains(fileExten))
        //        return BadRequest(new ActionStatus(-1, "文件格式不被支持"));

        //    IEnumerable<Student> lst = await ParseExcel(file);
        //    if (lst == null)
        //        return BadRequest(new ActionStatus(-1, "解析失败"));
        //    var cids = lst.Select(s => s.CitizenId).ToList();

        //    var cf = _studentCxt.Students.Where(s => cids.Contains(s.CitizenId)).ToArray();
        //    if (cf != null && cf.Count() > 0)
        //        _studentCxt.Students.RemoveRange(cf);
        //    _studentCxt.Students.AddRange(lst);
        //    int len = await _studentCxt.SaveChangesAsync();
        //    return Ok(new ActionStatus(200, $"导入成功{lst.Count()}条"));
        //}

        //private async Task<IEnumerable<Student>> ParseExcel(IFormFile file)
        //{
        //    var dirPath = Path.Combine(_webHostEnvironment.ContentRootPath + GlobalDefines.Temp);
        //    if (!Directory.Exists(dirPath))
        //        Directory.CreateDirectory(dirPath);
        //    string filePath = Path.Combine(dirPath, Guid.NewGuid().ToString() + Path.GetExtension(file.FileName));

        //    using (var fs = System.IO.File.Create(filePath))
        //    {
        //        await file.CopyToAsync(fs);
        //        fs.Flush();
        //        fs.Close();
        //    }

        //    var uds = _udCxt.UniversityDivisions.ToList();
        //    var minzu = _ekCxt.EthnicKinds.ToList();
        //    var city = _cityCxt.Districts.ToList();

        //    List<Student> lst = new List<Student>();

        //    using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
        //    {
        //        IWorkbook wb = WorkbookFactory.Create(fs);
        //        var sheet = wb.GetSheetAt(0);
        //        if (sheet != null)
        //        {
        //            int lastRowIx = sheet.LastRowNum + 1;
        //            for (int i = 1; i < lastRowIx; i++)
        //            {
        //                var row = sheet.GetRow(i);
        //                if (row == null)
        //                    break;
        //                Student stu = new Student();
        //                stu.Name = row.GetCell(0).ToString();

        //                stu.Gender = row.GetCell(1).ToString();
        //                stu.StuId = row.GetCell(2).ToString();
        //                stu.UName = stu.StuId;
        //                stu.HashedPwd = stu.StuId;


        //                stu.CitizenId = row.GetCell(3).ToString();

        //                stu.EthnicGroups = row.GetCell(4).ToString();
        //                if (!string.IsNullOrEmpty(stu.EthnicGroups))
        //                {
        //                    if (!stu.EthnicGroups.EndsWith("族")) stu.EthnicGroups += "族";
        //                    var t = minzu.Find(s => s.Name == stu.EthnicGroups);
        //                    if (t != null) stu.EthnicGroups = t.Id.ToString();
        //                    else return null;
        //                }
        //                else return null;

        //                stu.College = row.GetCell(5).ToString();
        //                if (!string.IsNullOrEmpty(stu.College))
        //                {
        //                    if (!stu.College.EndsWith("学院")) stu.College += "学院";
        //                    var t = uds.Find(s => s.Name == stu.College);
        //                    if (t != null) stu.College = t.Id.ToString();
        //                    else return null;
        //                }
        //                else return null;


        //                stu.Major = row.GetCell(6).ToString();
        //                if (!string.IsNullOrEmpty(stu.Major))
        //                {
        //                    var t = uds.Find(s => s.Name == stu.Major);
        //                    if (t != null) stu.Major = t.Id.ToString();
        //                    else return null;
        //                }
        //                else return null;

        //                stu.Degree = row.GetCell(7).ToString();

        //                string eYear = row.GetCell(8).ToString();
        //                DateTime dt = DateTime.Now;
        //                if (string.IsNullOrEmpty(eYear)) return null;
        //                else if (DateTime.TryParse(eYear, out dt))
        //                    stu.EnrollmentYear = dt;
        //                else return null;

        //                eYear = row.GetCell(9).ToString();//stu.GraduationYear
        //                if (string.IsNullOrEmpty(eYear)) return null;
        //                else if (DateTime.TryParse(eYear, out dt))
        //                    stu.GraduationYear = dt;
        //                else return null;

        //                stu.Phone = row.GetCell(10).ToString();

        //                stu.ProvinceBorn = row.GetCell(11).ToString();
        //                if (!string.IsNullOrEmpty(stu.ProvinceBorn))
        //                {
        //                    if (!stu.ProvinceBorn.EndsWith("省")) stu.ProvinceBorn += "省";
        //                    var t = city.Find(s => s.Name == stu.ProvinceBorn);
        //                    if (t != null) stu.ProvinceBorn = t.Id.ToString();
        //                    else return null;
        //                }
        //                else return null;


        //                stu.CityBorn = row.GetCell(12).ToString();
        //                if (!string.IsNullOrEmpty(stu.CityBorn))
        //                {
        //                    if (!stu.CityBorn.EndsWith("市")) stu.CityBorn += "市";
        //                    var t = city.Find(s => s.Name == stu.CityBorn);
        //                    if (t != null) stu.CityBorn = t.Id.ToString();
        //                    else return null;
        //                }
        //                else return null;

        //                stu.FamilyAddr = row.GetCell(13).ToString();
        //                lst.Add(stu);
        //            }
        //        }
        //        fs.Close();
        //    }

        //    lst = lst.DistinctBy(s => s.CitizenId).ToList();
        //    System.IO.File.Delete(filePath);

        //    return lst;
        //}
        #region 数据分析
        [HttpGet]
        public IActionResult GenderStatistics(string college)
        {
            int year = DateTime.Now.Year;
            var fiveYearAgo = DateTime.Parse($"{year - 5}-1-1");
            var rs = _stuResumeContext.Resumes.Where(s => s.BeginTime > fiveYearAgo).ToList().OrderByDescending(s => s.BeginTime).DistinctBy(s => s.CitizenId).ToList();//&& ((TimeSpan)(DateTime.Today - s.BeginTime)).TotalDays <= 365*5 
            var ids = rs.Select(s => s.CitizenId);

            var stus = _studentCxt.Students.Where(s => ids.Contains(s.CitizenId) && s.College == college);
            int maleCnt = stus.Count(s => s.Gender == GlobalDefines.GenderMale);
            int femaleCnt = stus.Count(s => s.Gender == GlobalDefines.GenderFemale);
            JsonObject js = new JsonObject
            {
                ["maleCnt"] = maleCnt,
                ["femaleCnt"] = femaleCnt
            };
            return Ok(new ActionStatus(200, "查询成功", js));
        }



        [HttpGet]
        public IActionResult MajorStatistics(string college)
        {
            var fiveYearAgo = DateTime.Now.AddYears(-5);
            var rs = _stuResumeContext.Resumes.Where(s => s.BeginTime > fiveYearAgo).ToList().OrderByDescending(s => s.BeginTime).DistinctBy(s => s.CitizenId).ToList();//&& ((TimeSpan)(DateTime.Today - s.BeginTime)).TotalDays <= 365*5             
            var ids = rs.Select(s => s.CitizenId);
            var stus = _studentCxt.Students.Where(s => ids.Contains(s.CitizenId) && s.College == college);//近五年的学生

            var majors = stus.Select(s => s.Major).Where(s => s != null).Distinct().ToArray();
            JsonArray ja = new JsonArray();
            var uds = _udCxt.UniversityDivisions.ToList();
            for (int i = 0; i < majors.Length; i++)
            {
                int cnt = stus.Count(s => s.Major == majors[i]);
                var ud = uds.Where(s => $"{s.Id}" == majors[i]).FirstOrDefault();
                if (ud == null)
                    continue;
                var majorName = ud.Name;
                JsonObject item = new JsonObject
                {
                    [$"{majorName}"] = cnt,
                };
                ja.Add(item);
            }
            return Ok(new ActionStatus(200, "查询成功", ja));
        }

        [HttpGet]
        public IActionResult CntYear(string college)
        {
            //Dictionary<string, int> yearCnt = new Dictionary<string, int>();
            int year = DateTime.Now.Year;
            var YearAgo1 = DateTime.Parse($"{year}-1-1");
            var YearAgo2 = DateTime.Parse($"{year - 1}-1-1");
            var YearAgo3 = DateTime.Parse($"{year - 2}-1-1");
            var YearAgo4 = DateTime.Parse($"{year - 3}-1-1");
            var YearAgo5 = DateTime.Parse($"{year - 4}-1-1");
            var oners = _stuResumeContext.Resumes.Where(s => s.BeginTime >= YearAgo1).ToList().DistinctBy(s => s.CitizenId);//&& ((TimeSpan)(DateTime.Today - s.BeginTime)).TotalDays <= 365*5             
            var oneids = oners.Select(s => s.CitizenId);
            var one = _studentCxt.Students.Where(s => oneids.Contains(s.CitizenId) && s.College == college).Count();//近五年的学生


            var twors = _stuResumeContext.Resumes.Where(s => s.BeginTime >= YearAgo2 && s.BeginTime < YearAgo1).ToList().DistinctBy(s => s.CitizenId);//&& ((TimeSpan)(DateTime.Today - s.BeginTime)).TotalDays <= 365*5             
            var twoids = twors.Select(s => s.CitizenId);
            var two = _studentCxt.Students.Where(s => twoids.Contains(s.CitizenId) && s.College == college).Count();//近五年的学生


            var threers = _stuResumeContext.Resumes.Where(s => s.BeginTime >= YearAgo3 && s.BeginTime < YearAgo2).ToList().DistinctBy(s => s.CitizenId);//&& ((TimeSpan)(DateTime.Today - s.BeginTime)).TotalDays <= 365*5             
            var threeids = threers.Select(s => s.CitizenId);
            var three = _studentCxt.Students.Where(s => twoids.Contains(s.CitizenId) && s.College == college).Count();//近五年的学生



            var fourrs = _stuResumeContext.Resumes.Where(s => s.BeginTime >= YearAgo4 && s.BeginTime < YearAgo3).ToList().DistinctBy(s => s.CitizenId);//&& ((TimeSpan)(DateTime.Today - s.BeginTime)).TotalDays <= 365*5             
            var fourids = fourrs.Select(s => s.CitizenId);
            var four = _studentCxt.Students.Where(s => twoids.Contains(s.CitizenId) && s.College == college).Count();//近五年的学生



            var fivers = _stuResumeContext.Resumes.Where(s => s.BeginTime >= YearAgo5 && s.BeginTime < YearAgo4).ToList().DistinctBy(s => s.CitizenId);//&& ((TimeSpan)(DateTime.Today - s.BeginTime)).TotalDays <= 365*5             
            var fiveids = fivers.Select(s => s.CitizenId);
            var five = _studentCxt.Students.Where(s => twoids.Contains(s.CitizenId) && s.College == college).Count();//近五年的学生



            JsonArray ja = new JsonArray();


            JsonObject ja1 = new JsonObject
            {
                [$"{DateTime.Now.Year}"] = one
            };
            JsonObject ja2 = new JsonObject
            {
                [$"{DateTime.Now.Year - 1}"] = two
            };
            JsonObject ja3 = new JsonObject
            {
                [$"{DateTime.Now.Year - 2}"] = three
            };
            JsonObject ja4 = new JsonObject
            {
                [$"{DateTime.Now.Year - 3}"] = four
            };
            JsonObject ja5 = new JsonObject
            {
                [$"{DateTime.Now.Year - 4}"] = five
            };

            return Ok(new ActionStatus(200, "查询成功", ja));
        }
        #endregion

    }
}
